//获取应用实例
const app = getApp();

Page({
  data: {
    typeid:'',
    goods:[],
    lo:'https://xiaochengxu.printeasy.top',
    'commodityList': [
      {
        'name':'（全新）墨仓式7色照片8色照片打印机',
        'author': 'AN-5454545',
        'cover': 'http://china.pr.img.coovee.net/picture/2014-6/18_17_27_56_015.jpg',
        'price': 88.2,
      },
      {
        'name': '（全新）针式打印机打印色照片打印机',
        'author': 'AN-5454543',
        'cover': 'http://china.pr.img.coovee.net/picture/2014-6/18_17_27_56_015.jpg',
        'price': 88.3,
      },
      {
        'name': '（全新）激光式7色照片8色照片打印机',
        'author': 'AN-545455',
        'cover': 'http://china.pr.img.coovee.net/picture/2014-6/18_17_27_56_015.jpg',
        'price': 88.4,
      },
    ],
    // 组件所需的参数
    nvabarData: {
      showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
      title: '采购详情', //导航栏 中间的标题
    },
    // 此页面 页面内容距最顶部的距离
    height: app.globalData.height * 2 + 20,
  },
  onLoad(options) {
    let id = options.id;
    let typeid = options.typeid;
    console.log(id)
    let that = this;
    let url = app.globalData.URL+'goods/commodity/wx/type/list/'+id;
        let data = {};
        app.wxRequest('GET', url, data, (res) => {
          console.log(res)
          let goods = res.rows
          that.setData({
            goods:goods,
            typeid:typeid
          })
          console.log(goods)
        }, (err) => {
          console.log(err.errMsg)
        })
  },
  gotoproduct_details:function(e){
    var id = e.currentTarget.dataset.id;
    if(this.data.typeid==0){
      wx.navigateTo({
        url: '/pages/shoppingcarts/product_details/product_details?id='+id,
        complete: (res) => {},
        fail: (res) => {},
        success: (result) => {
  
        },
      })
    }else if(this.data.typeid==1){
      wx.navigateTo({
        url: '/pages/shoppingcarts/product_detailsoffice/product_detailsoffice?id='+id,
        complete: (res) => {},
        fail: (res) => {},
        success: (result) => {
        },
      })
    }
    
  }
  
})
